﻿using System.Collections.Generic;
using Calimbra.Runtime.Contracts;
using Calimbra.Runtime.Data;
using Calimbra.Runtime.Functions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace Calimbra.Runtime.Test
{
    

    [TestClass()]
    public class Determine_operation_test
    {

        [TestMethod()]
        public void A_A()
        {
            var target = new Determine_operation();
            target.Inject(new Dictionary<string, IOperation>() { {"A", new Operation("A", null )} }); 
            Tuple<IMessage,IOperation> result = null;
            target.Result += output => result = output;

            target.Process(new Message("A", ""));

            Assert.AreEqual("A", result.Item1.Port.Fullname);
            Assert.AreEqual("A", result.Item2.Name);

        }

        [TestMethod()]
        public void AIn_A()
        {
            var target = new Determine_operation();
            target.Inject(new Dictionary<string, IOperation>() { { "A.in", new Operation("A.in", null) } });
            Tuple<IMessage, IOperation> result = null;
            target.Result += output => result = output;

            target.Process(new Message("A.in", ""));

            Assert.AreEqual("A.in", result.Item1.Port.Fullname);
            Assert.AreEqual("A.in", result.Item2.Name);
        }

        [TestMethod()]
        public void AName_AName()
        {
            var target = new Determine_operation();
            target.Inject(new Dictionary<string, IOperation>() { { "A.name", new Operation("A.name", null) } });
            Tuple<IMessage, IOperation> result = null;
            target.Result += output => result = output;

            target.Process(new Message("A.name", ""));

            Assert.AreEqual("A.name", result.Item1.Port.Fullname);
            Assert.AreEqual("A.name", result.Item2.Name);
        }
    }
}
